package commands;

/**
 * @author Rob Leister rleist1@students.towson.edu
 */
import IA.InformationAggregator;
import IA.Menu;
import IA.MenuItem;

public class CmdGetMostLeastOrdered extends Command {

    public CmdGetMostLeastOrdered(InformationAggregator IA) {
        super(IA);
    }

    @Override
    public java.lang.Object execute() {
        Menu m = ia.getMenu();
        String leastName = "NS";
        String mostName = "NS";
        Integer least = Integer.MAX_VALUE;
        Integer most = 0;
        Integer current;
        for (MenuItem item : m.getList()) {
            current = item.getDishesOrdered();
            if (current > most) {
                most = current;
                mostName = item.getName();
            } // end if most
            if (current < least) {
                least = current;
                if (least > 0) {
                    leastName = item.getName();
                }
            } // end if least
        }// end for
        String returnString = mostName + "/" + leastName;
        return returnString;
    }// end execute
}